package mysqlxa;

import java.sql.*;

/**
 * @author sjw
 * @className MySQLNoConnPool
 * @date 2020/12/14 8:05
 * @description: TODO
 */
public class MySQLNoConnPool {
    public static void main(String[] args) {
        // JDBC连接的URL, 不同数据库有不同的格式:
        String JDBC_URL = "jdbc:mysql://localhost:3306/app";
        String JDBC_USER = "root";
        String JDBC_PASSWORD = "123456";

        try {
            Connection connection=DriverManager.getConnection(JDBC_URL,JDBC_USER,JDBC_PASSWORD);
            Statement statement =connection.createStatement();
            connection.close();
            ResultSet resultSet= statement.executeQuery("select * from user");
            while (resultSet.next()){
                System.out.println(resultSet.getInt(1));
            }
            statement.close();
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
